package corej.course.thread.multiThread;

public class TestJoin {
    public static void main(String[] args) {
        Thread t1 = new NumberThread();
        CharThread t2 = new CharThread();
        t2.setT(t1);

        t1.start();
        t2.start();
    }

}

class NumberThread extends Thread {
    public void run() {
        for (int i = 1; i <= 26; i++) {
            System.out.println(i * 2 - 1);
            System.out.println(i * 2);
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}

class CharThread extends Thread {

    Thread t;

    public void setT(Thread t) {
        this.t = t;
    }

    public void run() {
        for (char c = 'A'; c <= 'Z'; c++) {
            System.out.println(c);
            try {
                Thread.sleep(500);
                if (c == 'D')
                    t.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
